]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
userWidget: Adapt if user is not mentioned for username login
authorUmang Jain <mailumangjain@gmail.com>
Fri, 17 Jan 2020 06:47:34 +0000 (12:17 +0530)
committerFlorian Müllner <florian.muellner@gmail.com>
Wed, 12 Feb 2020 19:29:48 +0000 (19:29 +0000)
If username-based login flow is followed, we need a default avatar
for the userWidget. Hence, check if the user passed to userWidget
is (null) which implies a username-based login flow.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/922

js/gdm/authPrompt.js
js/ui/userWidget.js

index 5723ce5426ca2cdba046f48f185615b9d6b2da98..2fb5057b8423e599951dfffac7882af5b96d8ca2 100644 (file)
@@ -424,10 +424,8 @@ var AuthPrompt = GObject.registerClass({
         if (oldChild)
             oldChild.destroy();
 
-        if (user) {
-            let userWidget = new UserWidget.UserWidget(user, Clutter.Orientation.VERTICAL);
-            this._userWell.set_child(userWidget);
-        }
+        let userWidget = new UserWidget.UserWidget(user, Clutter.Orientation.VERTICAL);
+        this._userWell.set_child(userWidget);
     }
 
     reset() {
index 22446510a46e35b4da233bc1475b9b4ec65940c2..d21552555c8aed45c25528df1e3e32ef9d3fe11a 100644 (file)
@@ -86,9 +86,12 @@ class Avatar extends St.Bin {
     update() {
         let iconSize = this._getIconSize();
 
-        let iconFile = this._user.get_icon_file();
-        if (iconFile && !GLib.file_test(iconFile, GLib.FileTest.EXISTS))
-            iconFile = null;
+        let iconFile = null;
+        if (this._user) {
+            iconFile = this._user.get_icon_file();
+            if (iconFile && !GLib.file_test(iconFile, GLib.FileTest.EXISTS))
+                iconFile = null;
+        }
 
         if (iconFile) {
             this.child = null;
@@ -192,6 +195,7 @@ class UserWidgetLabel extends St.Widget {
 var UserWidget = GObject.registerClass(
 class UserWidget extends St.BoxLayout {
     _init(user, orientation = Clutter.Orientation.HORIZONTAL) {
+        // If user is null, that implies a username-based login authorization.
         this._user = user;
 
         let vertical = orientation == Clutter.Orientation.VERTICAL;
@@ -210,14 +214,19 @@ class UserWidget extends St.BoxLayout {
         this._avatar.x_align = Clutter.ActorAlign.CENTER;
         this.add_child(this._avatar);
 
-        this._label = new UserWidgetLabel(user);
-        this.add_child(this._label);
+        this._userLoadedId = 0;
+        this._userChangedId = 0;
+        if (user) {
+            this._label = new UserWidgetLabel(user);
+            this.add_child(this._label);
 
-        this._label.bind_property('label-actor', this, 'label-actor',
-                                  GObject.BindingFlags.SYNC_CREATE);
+            this._label.bind_property('label-actor', this, 'label-actor',
+                                      GObject.BindingFlags.SYNC_CREATE);
+
+            this._userLoadedId = this._user.connect('notify::is-loaded', this._updateUser.bind(this));
+            this._userChangedId = this._user.connect('changed', this._updateUser.bind(this));
+        }
 
-        this._userLoadedId = this._user.connect('notify::is-loaded', this._updateUser.bind(this));
-        this._userChangedId = this._user.connect('changed', this._updateUser.bind(this));
         this._updateUser();
     }